/**
* @file			keypad.c
* @author  		Chamalinda Mandawala
* @date    		December 06, 2014
* @brief 			4x4 Matix keypad compatibility module
*/

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_conf.h"
#include "stm32f0xx_gpio.h"
#include "stm32f0xx.h"
#include "keypad.h"
#include "keypadwrite.h"

//Implementation of the keypad_status()
int keypad_status(){
	
if(keypadwrite()<10){
return 1;
}
else return 0;
}


//Implementation of the read_code()
int read_code(){

int code;
int i;

for (i=1; i<5; i++){
if(i==1){
while(!keypad_status()){};
	code = code + keypadwrite() * 1000;
}

if(i==2){
while(!keypad_status()){};
	code = code + keypadwrite() * 100;
}

if(i==3){
while(!keypad_status()){};
	code = code + keypadwrite() * 10;
}

if(i==4){
while(!keypad_status()){};
	code = code + keypadwrite();  
}return code;
}

}







